//
//  SQUserInformationViewController.m
//  energy
//
//  Created by 周曼迪 on 2021/7/18.
//

#import "SQUserInformationViewController.h"

#import "SQMyModel.h"

#import "SQUserInformationModel.h"



@interface SQUserInformationViewController ()
@property (weak, nonatomic) IBOutlet UITextField *tf_tel;

@property (weak, nonatomic) IBOutlet UITextField *tf_name;
@property (weak, nonatomic) IBOutlet UITextField *tf_department;

/**公司*/
@property (weak, nonatomic) IBOutlet UIView *viwe_company;
@property (weak, nonatomic) IBOutlet UITextField *tf_company;

/**车间*/
@property (weak, nonatomic) IBOutlet UIView *view_workshop;
@property (weak, nonatomic) IBOutlet UITextField *tf_workshop;

/**班组*/
@property (weak, nonatomic) IBOutlet UIView *view_class;
@property (weak, nonatomic) IBOutlet UITextField *tf_class;

/**岗位*/
@property (weak, nonatomic) IBOutlet UITextField *tf_jobs;
@property (weak, nonatomic) IBOutlet UIView *view_jobs;


@end

@implementation SQUserInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"用户信息";
    [self getData];
}

-(void)getData{
    [SQMyModel getDataWithParams:@{@"m_id":UID} WithCallBack:^(SQMyModel * data) {
//        self.myModel = data;
        self.tf_name.text = data.data.m_name;
        self.tf_department.text = data.data.m_title;
        self.tf_company.text = data.data.m_one_text;
        self.tf_tel.text = data.data.m_phone;
        self.tf_workshop.text = data.data.m_two_text;
        self.tf_class.text = data.data.m_three_text;
        self.tf_jobs.text = data.data.m_four_text;
        if ([data.data.m_two_text isEqualToString:@""]) {
            self.view_workshop.hidden = YES;
        }
        
        if ([data.data.m_three_text isEqualToString:@""]) {
            self.view_class.hidden = YES;
        }

        if ([data.data.m_four_text isEqualToString:@""]) {
            self.view_jobs.hidden = YES;
        }

        
//        [self.imgV_pic setImageWithURL:[NSURL URLWithString:data.data.m_pic] placeholder:[UIImage imageNamed:@"header"]];
    }];
}

//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།
- (IBAction)clickConfirm:(UIButton *)sender {
    [SQUserInformationModel getDataWithParams:@{@"m_name":self.tf_name.text,@"m_phone":self.tf_tel.text,@"m_userpass":@"",@"m_id":UID} WithCallBack:^(SQUserInformationModel * data) {
        [CCToast showMessage:@"修改成功"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"userInformation" object:nil];
        [self.navigationController popViewControllerAnimated:YES];
        
    }];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
